<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "student_status".
 *
 * @property int $ID ID
 * @property string $XJBH 学籍编号
 * @property int $GRID 个人ID
 * @property int $XSID 学生ID
 * @property string $XQ 学期
 * @property string $XXMC 学校名称
 * @property string $ZYMC 专业名称
 * @property string $BJBH 班级编号
 * @property string $XJZT 学籍状态
 * @property string|null $FJDM 附件代码
 * @property string $XJDJR 学籍登记人
 * @property string $DJSJ 登记时间
 * @property string|null $SHZT 审核状态
 * @property string|null $SHR 审核人
 * @property string|null $SHSJ 审核时间
 *
 * @property Student $xS
 * @property Person $gR
 */
class StudentStatus extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'student_status';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['XJBH', 'GRID', 'XSID', 'XQ', 'XXMC', 'ZYMC', 'BJBH', 'XJZT', 'XJDJR', 'DJSJ'], 'required'],
            [['GRID', 'XSID'], 'integer'],
            [['DJSJ', 'SHSJ'], 'safe'],
            [['XJBH', 'XQ'], 'string', 'max' => 20],
            [['XXMC', 'ZYMC', 'FJDM', 'XJDJR', 'SHR'], 'string', 'max' => 50],
            [['BJBH', 'XJZT', 'SHZT'], 'string', 'max' => 10],
            [['FJDM'], 'unique'],
            [['XSID'], 'exist', 'skipOnError' => true, 'targetClass' => Student::className(), 'targetAttribute' => ['XSID' => 'ID']],
            [['GRID'], 'exist', 'skipOnError' => true, 'targetClass' => Person::className(), 'targetAttribute' => ['GRID' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'XJBH' => '学籍编号',
            'GRID' => '个人ID',
            'XSID' => '学生ID',
            'XQ' => '学期',
            'XXMC' => '学校名称',
            'ZYMC' => '专业名称',
            'BJBH' => '班级编号',
            'XJZT' => '学籍状态',
            'FJDM' => '附件代码',
            'XJDJR' => '学籍登记人',
            'DJSJ' => '登记时间',
            'SHZT' => '审核状态',
            'SHR' => '审核人',
            'SHSJ' => '审核时间',
        ];
    }

    /**
     * Gets query for [[XS]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getXS()
    {
        return $this->hasOne(Student::className(), ['ID' => 'XSID'])->inverseOf('studentStatuses');
    }

    /**
     * Gets query for [[GR]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getGR()
    {
        return $this->hasOne(Person::className(), ['id' => 'GRID'])->inverseOf('studentStatuses');
    }
}
